<template>
    <ExtForm ref="ExtForm" :formfields="formfields" @changeEventHandler="changeEventHandler"></ExtForm>
</template>
<script>

import pageSetting from '@/components/lt/codeGenerator/pageSetting'
import Vue from 'vue'
import ExtForm from '@/components/lt/codeGenerator/components/ExtForm'


export default {
    name:'TreeAttribute',
    components:{ExtForm},
    props:{
        component:{
           type:Object,
           default:()=>{}
        },
    },
    watch:{
        
    },
    data(){
        return{
            pageSetting,
            formfields:[
                {field:'label',label:'标题',component:pageSetting.常量.表单组件类型.单行文本,initialValue:this.component.label},
                {field:'ref',label:'ref',component:pageSetting.常量.表单组件类型.单行文本,initialValue:this.component.ref,disabled:true},
                {field:'axiosUrl',label:'请求地址',component:pageSetting.常量.表单组件类型.单行文本,initialValue:this.component.props["axiosUrl"],rules: [{ required: true, message: '不能为空!' }]},
                {field:'axiosMethod',label:'请求类型',component:pageSetting.常量.表单组件类型.下拉选择,initialValue:this.component.props["axiosMethod"],options:pageSetting.数据字典.请求类型,rules: [{ required: true, message: '不能为空!' }]},
                {field:'param',label:'请求参数',component:pageSetting.常量.表单组件类型.单行文本,initialValue:this.component.props["param"]},
                {field:'replaceFields',label:'替换字段(JSON对象)',component:pageSetting.常量.表单组件类型.单行文本,initialValue:this.component.props["replaceFields"],},
                {field:'checkable',label:'是否添加复选框',component:pageSetting.常量.表单组件类型.开关,checkedChildren:true,unCheckedChildren:false,initialValue:this.component.props["checkable"]},
                {field:'checkStrictly',label:'父子节点是否关联',component:pageSetting.常量.表单组件类型.开关,checkedChildren:true,unCheckedChildren:false,initialValue:this.component.props["checkStrictly"]},
                {field:'autoExpandParent',label:'是否自动展开',component:pageSetting.常量.表单组件类型.开关,checkedChildren:true,unCheckedChildren:false,initialValue:this.component.props["autoExpandParent"]},
                {field:'showLine',label:'是否显示连接线',component:pageSetting.常量.表单组件类型.开关,checkedChildren:true,unCheckedChildren:false,initialValue:this.component.props["showLine"]},
                {field:'treeCheck',label:'点击复选框事件',component:pageSetting.常量.表单组件类型.单行文本,initialValue:this.component.props["treeCheck"]},
                {field:'treeSelect',label:'点击树节点事件',component:pageSetting.常量.表单组件类型.单行文本,initialValue:this.component.props["treeSelect"]},
           
           ]
        }
    },
   
    created(){
        
    },
    methods:{
        changeEventHandler(item){
         
            if(item["label"]){
                this.component.label=item.label
                for(let i=0;i<this.component.components.length;i++){
                    if(this.component.components[i].type==pageSetting.常量.组件.标题){
                        this.component.components[i].label=item.label
                    }
                }
            }else{
                for (const key in item) {
                    Vue.set(this.component.props,key,item[key]) 
                }
            }

        }
    }
}
</script>